from datetime import datetime

from sqlmodel import Field, SQLModel


class RefreshTokenRequest(SQLModel):
    refresh_token: str = Field(default="", max_length=500, nullable=False)


class TokenResponse(RefreshTokenRequest):
    access_token: str = Field(default="", max_length=500, nullable=False)


class TokenBlacklist(SQLModel, table=True):
    __tablename__ = "token_blacklist"
    id: int = Field(default=None, primary_key=True, index=True)
    token: str = Field(
        default="", max_length=500, unique=True, index=True, nullable=False
    )
    expires_at: datetime = Field(default=..., nullable=False)
    created_at: datetime = Field(default_factory=datetime.now, nullable=False)
